import router from '@/router/index'
import store from '@/store/index'

// 不需登录de页面
const widthRouterList = ['login']

// 全局前置守卫
router.beforeEach((to, from,next) => {
  console.log("导航守卫")
  if(!widthRouterList.includes(to.name)){
    // 需要登录页面，判断有没有登录
    if(store.getters.getToken){
      next()
    }else{
      next({name:'login'})
    }
  }else{
    next()
  }
})
